package com.example.graduationdesign.utils;


import com.example.graduationdesign.pojo.vo.EmailReceiver;

/**
 * Email util
 */
public class EmailUtil {

    private final static String HEAD = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"></head><body>";
    private final static String FOOT = "</body></html>";

    /**
     * 注册邮箱验证码邮件格式
     *
     * @param emailReceiver 邮件信息
     * @return 邮件格式
     */
    public static String verificationCodeEmailFormat(EmailReceiver emailReceiver) {
        EmailReceiver.Content content = emailReceiver.getContent();
        StringBuilder text = new StringBuilder();
        text.append(HEAD);
        System.out.println(text);
        text.append("<h2 style=\"margin-left: 150px;\">").append(content.getTitle()).append("</h2>");
        text.append("<p style=\"width: 500px;\">").append(content.getText()).append("</p>");
        text.append("<h4>验证码: ").append(content.getCode()).append("</h4>");
        text.append("<div>萤火系统发送的验证码将在<b>").append(content.getExpirationTime()).append("分钟</b>内有效</div>");
        text.append(FOOT);
        System.out.println(text);
        return String.valueOf(text);
    }


    /**
     *
     * @param emailReceiver
     * @return 注册邮箱邮件格式
     */
    public static String verificationCodeEmailFormatRegister(EmailReceiver emailReceiver) {
        EmailReceiver.Content content = emailReceiver.getContent();
        StringBuilder text = new StringBuilder();
        text.append(HEAD);
        System.out.println(text);
        text.append("<h2 style=\"margin-left: 150px;\">").append(content.getTitle()).append("</h2>");
        text.append("<p style=\"width: 500px;\">").append(content.getText()).append("</p>");
        text.append("<h4>验证码: ").append(content.getCode()).append("</h4>");
        text.append("<div>萤火系统发送的验证码将在<b>").append(content.getExpirationTime()).append("分钟</b>内有效</div>");
        text.append(FOOT);
        System.out.println(text);
        return String.valueOf(text);
    }



    /**
     *
     * @param emailReceiver
     * @return 修改邮箱时所需要发送的邮件格式
     */
    public static String verificationCodeEmailFormatModifyEmail(EmailReceiver emailReceiver) {
        EmailReceiver.Content content = emailReceiver.getContent();
        StringBuilder text = new StringBuilder();
        text.append(HEAD);
        System.out.println(text);
        text.append("<h2 style=\"margin-left: 150px;\">").append(content.getTitle()).append("</h2>");
        text.append("<p style=\"width: 500px;\">").append(content.getText()).append("</p>");
        text.append("<h4>验证码: ").append(content.getCode()).append("</h4>");
        text.append("<div>萤火系统发送的验证码将在<b>").append(content.getExpirationTime()).append("分钟</b>内有效</div>");
        text.append(FOOT);
        System.out.println(text);
        return String.valueOf(text);
    }

}
